package au.com.handsunited.utils.constants;

import java.util.Map;
import java.util.TreeMap;

import org.apache.commons.lang.StringUtils;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * @author arunda
 *
 */
public class DateConstants {

	private static Logger logger = LoggerFactory.getLogger(DateConstants.class);


	private Map<String, String> pastYears;
	private Map<String, String> futureYears;
	private Map<String, String> months;
	private Map<String, String> days;
	private Map<String, String> hours;
	private Map<String, String> minutes;

	/**
	 *
	 */
	public DateConstants() {
		super();
		initialiseDays();
		initialisePastYears();
		initialiseFutureYears();
		initialiseHours();
		initialiseMinutes();
	}


	/**
	 * @return the pastYears
	 */
	public Map<String, String> getPastYears() {
		return pastYears;
	}

	/**
	 * @return the futureYears
	 */
	public Map<String, String> getFutureYears() {
		return futureYears;
	}

	/**
	 * @return the months
	 */
	public Map<String, String> getMonths() {
		return months;
	}

	/**
	 * @param months the months to set
	 */
	public void setMonths(Map<String, String> months) {
		this.months = months;
	}


	/**
	 * @return the days
	 */
	public Map<String, String> getDays() {
		return days;
	}

	/**
	 * @return the hours
	 */
	public Map<String, String> getHours() {
		return hours;
	}

	/**
	 * @return the minutes
	 */
	public Map<String, String> getMinutes() {
		return minutes;
	}

	/**
	 *
	 */
	private void initialisePastYears() {
		pastYears = new TreeMap<String, String>();
		for (int i=1900; i <= new DateTime().getYear(); i++) {
			pastYears.put(i+"", i+"");
		}
	}

	/**
	 *
	 */
	private void initialiseFutureYears() {
		futureYears = new TreeMap<String, String>();
		int currentYear = new DateTime().getYear();
		for (int i=0; i<20; i++) {
			futureYears.put((currentYear + i + ""), (currentYear + i + ""));
		}
	}

	/**
	 *
	 */
	private void initialiseDays() {
		days = new TreeMap<String, String>();
		for (int i=1; i<=31; i++) {
			days.put(StringUtils.leftPad((i+""), 2, '0'), StringUtils.leftPad((i+""), 2, '0'));
		}
	}

	/**
	 *
	 */
	private void initialiseMinutes() {
		minutes = new TreeMap<String, String>();
		for (int i=0; i<60; i+=15) {
			minutes.put(StringUtils.leftPad((i+""), 2, '0'), StringUtils.leftPad((i+""), 2, '0'));
		}
	}

	/**
	 *
	 */
	private void initialiseHours() {
		hours = new TreeMap<String, String>();
		for (int i=0; i<24; i++) {
			hours.put(StringUtils.leftPad((i+""), 2, '0'), StringUtils.leftPad((i+""), 2, '0'));
		}
	}

}
